<!--
@author	Yi Bo <etng2004@gmail.com>
@version	$Id: contact_list.php 59 2007-09-10 03:35:38Z etng2004 $
@copyrithg	2006-2007 ETE.CN
@license 	PHP Version 3.0 {@link http://www.php.net/license/3_0.txt}
-->
<?php
$this->declareVars();
require_once(dirname(__FILE__) . '/_meta_contact.php');
echo $this->render('header.php');
//$this->dump($this->contacts);

/**
 * 列表相应参数
 */
$checkbox_group = 'Contact';
?>
<script type="text/javascript">
<!--
function validateBatchOperateForm(checkboxGroup)
{
	var errors=[];
	if(!checkboxGroup.selected.length)errors.push('请选择至少一个对象！');

//	var f_status = document.getElementById('field_status');
//	var v_status = f_status.options[f_status.selectedIndex].value;
//	if(v_status=="")errors.push('请选择至少一种批量操作！');

	if(errors.length)
	{
		alert("请纠正以下错误后再继续操作：\n\n"+errors.join("\n"));
		return false;
	}
	return true;
}
//-->
</script>

<table cellspacing="0" cellpadding="0" border="0" width="100%">
  <tr>
    <td><!--表头区域，可以用来做搜索等信息的展示-->
    </td>
  </tr>
  <tr>
    <td align="center" valign="top"><form method="post" action="<?php echo $this->base_url; ?>/batchOperate/" id="frmBatchOperate" name="frmBatchOperate" onSubmit="return validateBatchOperateForm(<?php echo $checkbox_group;?>ChkGroup);">
        <table cellspacing="0" cellpadding="0" id="<?php echo strtolower($checkbox_group);?>_list" class="tblborder">
          <tr class="tblhead">
            <td> - </td>
            <td><?php echo $meta['contact']['fields']['id'];?></td>
            <td><?php echo $meta['contact']['fields']['client_id'];?></td>
            <td><?php echo $meta['contact']['fields']['name'];?></td>
            <td><?php echo $meta['contact']['fields']['email'];?></td>
            <td><?php echo $meta['contact']['fields']['qq'];?></td>
            <td><?php echo $meta['contact']['fields']['phone'];?></td>
            <td><?php echo $meta['contact']['fields']['cellphone'];?></td>
            <td><?php echo $meta['contact']['fields']['is_primary'];?></td>
            <td><?php echo $meta['contact']['fields']['memo'];?></td>
            <td><?php echo $meta['contact']['fields']['created_at'];?></td>
            <td><?php echo $meta['contact']['fields']['updated_at'];?></td>
            <td> 操作 </td>
          </tr>
          <?php
        if(!$this->contacts):
	?>
          <tr class="tblbody">
            <td colspan="20"> 无记录
            </td>
          </tr>
          <?php
        else:
        foreach ($this->contacts as $contact):
	?>
          <tr class="tblbody">
            <td><input type="checkbox" name="fields[<?php echo strtolower($checkbox_group);?>_id][]" id="fields_<?php echo strtolower($checkbox_group);?>_<?php echo $contact['id']; ?>" value="<?php echo $contact['id']; ?>"/>
            </td>
            <td><?php echo $contact['id'] ?></td>
            <td><?php echo $contact['client_id'];?></td>
            <td><?php echo $contact['name'];?></td>
            <td><a href="mailto:"><?php echo $contact['email'];?></a> </td>
            <td><?php echo $contact['qq'];?></td>
            <td><?php echo $contact['phone'];?></td>
            <td><?php echo $contact['cellphone'];?></td>
            <td><?php echo $contact['is_primary'];?></td>
            <td><?php echo $contact['memo'];?></td>
            <td><?php echo date('Y-m-d', $contact['created_at']);?></td>
            <td><?php echo date('Y-m-d', $contact['updated_at']);?></td>
            <td>
            <a href="<?php echo $this->base_url;?>/view/id/<?php echo $contact['id'] ?>">查看</a>
            <?php
            if($contact['is_primary']=='N'):
            ?>
 <a href="<?php echo $this->module_url;?>/contact/primary/client/<?php echo $contact['client_id'];?>/id/<?php echo $contact['id'] ?>">设为主要</a>
            <?php
            endif;
            ?>
            <a href="<?php echo $this->base_url;?>/edit/id/<?php echo $contact['id'] ?>">编辑</a>
            <a href="<?php echo $this->base_url;?>/remove/id/<?php echo $contact['id'] ?>">删除</a> </td>
          </tr>
          <?php
        endforeach;
	?>
          <tr class="tblfoot">
            <td colspan="20"><a href="javascript:void(0);" onClick="<?php echo $checkbox_group;?>ChkGroup.all();">全选</a> <a href="javascript:void(0);" onClick="<?php echo $checkbox_group;?>ChkGroup.inverse();">反选</a> <a href="javascript:void(0);" onClick="<?php echo $checkbox_group;?>ChkGroup.clear();">不选</a> 对选中的对象：
              <select name="operate[status]" id="field_status">
                <option value="">===审核===</option>
                <?php
$lang_status_op = array();
foreach ($lang_status_op as $status => $text) {
	if($this->status==$status)continue;
	echo "<option value=\"{$status}\">{$text}</option>\n";
}
  ?>
              </select>
              <input type="submit" value="设置"  />
            </td>
          </tr>
          <tr class="tblfoot">
            <td colspan="20"><?php
          echo $this->pagination($this->pager['total'], $this->pager['curpage'], $this->pager['perpage'], $this->pager['url'] );
?>
            </td>
          </tr>
          <?php
        endif;
	?>
        </table>
      </form>
      <script type="text/javascript">
      <!--
      var <?php echo $checkbox_group;?>ChkGroup = new EtCheckboxes('<?php echo strtolower($checkbox_group);?>_list','fields_<?php echo strtolower($checkbox_group);?>_',[]);
      //-->
</script>
    </td>
  </tr>
  <tr>
    <td>others</td>
  </tr>
</table>
<br />

<?php
if($this->client):
require_once(dirname(__FILE__) . '/_meta_client.php');
$client = $this->client;
?>
<h2>基本信息</h2>
<?php echo date('Y-m-d', $client['created_at']); ?>
<hr />
<div class="content">
<table>
  <tr>
    <td><?php echo $meta['client']['fields']['id'];?></td>
    <td><?php echo $client['id'];?></td>
  </tr>
  <tr>
    <td><?php echo $meta['client']['fields']['client_type_code'];?></td>
    <td><?php echo $this->client_types[$client['client_type_code']];?></td>
  </tr>
  <tr>
    <td><?php echo $meta['client']['fields']['trade_type_id'];?></td>
    <td><?php echo $this->trade_types[$client['trade_type_id']];?></td>
  </tr>
  <tr>
    <td><?php echo $meta['client']['fields']['company'];?></td>
    <td><?php echo $client['company'];?></td>
  </tr>
  <tr>
    <td><?php echo $meta['client']['fields']['website'];?></td>
    <td><?php echo $client['website'];?></td>
  </tr>
  <tr>
    <td><?php echo $meta['client']['fields']['phone'];?></td>
    <td><?php echo $client['phone'];?></td>
  </tr>
  <tr>
    <td><?php echo $meta['client']['fields']['fax'];?></td>
    <td><?php echo $client['fax'];?></td>
  </tr>
  <tr>
    <td><?php echo $meta['client']['fields']['email'];?></td>
    <td><?php echo $client['email'];?></td>
  </tr>
  <tr>
    <td><?php echo $meta['client']['fields']['address'];?></td>
    <td><?php echo $client['address'];?></td>
  </tr>
  <tr>
    <td><?php echo $meta['client']['fields']['postcode'];?></td>
    <td><?php echo $client['postcode'];?></td>
  </tr>
  <tr>
    <td><?php echo $meta['client']['fields']['stage'];?></td>
    <td><?php echo $client['stage'];?></td>
  </tr>
  <tr>
    <td><?php echo $meta['client']['fields']['memo'];?></td>
    <td><?php echo $client['memo'];?></td>
  </tr>
  <tr>
    <td><?php echo $meta['client']['fields']['contact_name'];?></td>
    <td><?php echo $client['contact_name'];?></td>
  </tr>
  <tr>
    <td><?php echo $meta['client']['fields']['contact_email'];?></td>
    <td><?php echo $client['contact_email'];?></td>
  </tr>
  <tr>
    <td><?php echo $meta['client']['fields']['contact_msn'];?></td>
    <td><?php echo $client['contact_msn'];?></td>
  </tr>
  <tr>
    <td><?php echo $meta['client']['fields']['contact_qq'];?></td>
    <td><?php echo $client['contact_qq'];?></td>
  </tr>
  <tr>
    <td><?php echo $meta['client']['fields']['contact_cellphone'];?></td>
    <td><?php echo $client['contact_cellphone'];?></td>
  </tr>
  <tr>
    <td><?php echo $meta['client']['fields']['last_contact_at'];?></td>
    <td><?php echo $client['last_contact_at'];?></td>
  </tr>
  <tr>
    <td><?php echo $meta['client']['fields']['last_contact_by'];?></td>
    <td><?php echo $client['last_contact_by'];?></td>
  </tr>
  <tr>
    <td><?php echo $meta['client']['fields']['created_at'];?></td>
    <td><?php echo $client['created_at'];?></td>
  </tr>
  <tr>
    <td><?php echo $meta['client']['fields']['updated_at'];?></td>
    <td><?php echo $client['updated_at'];?></td>
  </tr>
  <tr>
    <td><?php echo $meta['client']['fields']['deleted_at'];?></td>
    <td><?php echo $client['deleted_at'];?></td>
  </tr>
</table>
<?php
endif;
?>
<?php
echo $this->render('footer.php');
?>